function quickSort(arr, start = 0, end = arr.length - 1) {
    if (end - start < 1) return;
    let piovtIndex = partition(arr, start, end);
    quickSort(arr, start, piovtIndex - 1);
    quickSort(arr, piovtIndex + 1, end);
    return arr;
}

function partition(arr, start, end) {
    let i = start;
    let piovt = arr[end];
    for (let j = start; j <= end; j++) {
        if (arr[j] <= piovt) {
            [arr[j], arr[i]] = [arr[i], arr[j]];
            i++;
        }
    }
    return i - 1;
}

const arr = [4, 1, 5, 2, 6, 3];
console.log(quickSort(arr));
